#include "StdAfx.h"
#include "Randomizer.h"

Randomizer::Randomizer(void)
{
}

Randomizer::~Randomizer(void)
{
}

double Randomizer::NextDouble()
{
	return (NextInt()/(double)RAND_MAX)-.5;
}

double Randomizer::NextPositiveDouble()
{
	return (NextInt()/(double)RAND_MAX);	
}

int Randomizer::NextInt()
{
	return rand();
}

int Randomizer::NextInt(int begin, int end)
{
    // This is not the best algorithm, but it is fast and will be enough in most cases
    // (see Google for best approaches)

    return rand() % (end - begin + 1) + begin;
}


short Randomizer::NextShort()
{
	return (short) (NextDouble()*SHORT_MAX);
}